package com.code;

/**
 * 描述:
 * leetcode 27题
 *
 * @author luzhongfu
 * @create 2018-12-23 9:26 PM
 */
public class Code27 {

    public int removeElement(int[] nums, int val) {
        int k = nums.length;
        if(k == 1 && nums[k - 1] == val){
            return 1;
        }
        for (int i = 0 ; i < nums.length - 1; i ++){
            if(nums[i] == val && nums[i + 1] != val){
                nums[i] = nums[i + 1];
            }

        }
        return nums.length - k;
    }
}
